#include "MyVector.h"

#include <iostream>

using namespace std;

MyVector::MyVector(const MyVector& that) : size(that.size), capacity(that.capacity), data(new int[that.capacity]) {
    for (int i = 0; i < size; i++) data[i] = that.data[i];
}

void MyVector::push_back(const int& value) {
    if (size >= capacity) {
        int* temp = new int[size];
        for (int i = 0; i < size; i++) temp[i] = data[i];

        cout << "capacity increase:" << capacity << "->";
        capacity = capacity ? 2 * capacity : 1;
        cout << capacity << endl;

        delete[] data;
        data = new int[capacity];
        for (int i = 0; i < size; i++) data[i] = temp[i];
        delete[] temp;
    }
    size++;
    data[size] = value;
}

int MyVector::get_size() const { return size; }
const int& MyVector::at(int index) const { return data[index]; }